﻿namespace EFS.RC.CC.Config.Scheduler
{
	public class TimeInterval : EFS.Common.Serialization.ISerializable
	{
		/// <summary>
		/// Handlers
		/// </summary>
		public enum Handlers
		{
 			Hunt,
			AfterHours
		}

		/// Start Time : Get, Set
		public EFS.RC.CC.Config.Scheduler.Time StartTime { get; private set; }

		/// Finish Time : Get, Set
		public EFS.RC.CC.Config.Scheduler.Time FinishTime { get; private set; }

		/// <summary>
		/// Handler
		/// </summary>
		public EFS.RC.CC.Config.Scheduler.TimeInterval.Handlers Handler { get; private set; }

		/// <summary>
		/// Constructor
		/// </summary>
		public TimeInterval()
		{
			StartTime = new Time();
			FinishTime = new Time();
		}

		/// Serialize
		public void Serialize(EFS.Common.Serialization.XmlWriter xmlWriter)
		{
			// write
			StartTime.Serialize("StartTime", xmlWriter);
			FinishTime.Serialize("FinishTime", xmlWriter );
			xmlWriter.Write("Handler", System.Enum.GetName(typeof(Handlers), Handler));
		}

		/// Deserialize
		public void Deserialize(EFS.Common.Serialization.XmlReader xmlReader)
		{
			// read
			StartTime.Deserialize("StartTime", xmlReader);
			FinishTime.Deserialize("FinishTime", xmlReader);
			System.String handler = xmlReader.Read("Handler");
			Handler = (Handlers)System.Enum.Parse(typeof(Handlers), handler);
		}
	}
}